package net.learn.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.learn.framework.common.page.PageResult;
import net.learn.framework.common.utils.Result;
import net.learn.system.query.SysCheckBoxQuery;
import net.learn.system.query.SysRadioQuery;
import net.learn.system.service.SysCheckBoxDetailService;
import net.learn.system.service.SysCheckBoxService;
import net.learn.system.vo.SysCheckBoxDetailVO;
import net.learn.system.vo.SysCheckBoxVO;
import net.learn.system.vo.SysRadioVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 多选管理
 */
@RestController
@RequestMapping("sys/checkbox")
@Tag(name="多选管理")
@AllArgsConstructor
public class SysCheckBoxController {
    @Autowired
    SysCheckBoxService checkBoxService;
    @Autowired
    SysCheckBoxDetailService checkBoxDetailService;

    @GetMapping("getCheckBox")
    @Operation(summary = "分页获取多选题列表")
    public Result<PageResult<SysCheckBoxVO>> getCheckBox(@Valid SysCheckBoxQuery query){
        PageResult<SysCheckBoxVO> page = checkBoxService.qryCheckBoxListPage(query);
        return Result.ok(page);
    }
    @PostMapping("getCheckBoxList")
    @Operation(summary = "获取多选列表")
    public Result<List<SysCheckBoxVO>> getCheckBoxList(@RequestBody @Valid SysCheckBoxQuery query){
        List<SysCheckBoxVO> list = checkBoxService.qryCheckBoxList();

        return Result.ok(list);
    }
    @PostMapping("getCheckBoxPaper")
    @Operation(summary = "获取试卷多选列表")
    public Result<List<SysCheckBoxVO>> getCheckBoxPaper(@RequestBody @Valid SysCheckBoxQuery query){
        List<SysCheckBoxVO> list = checkBoxService.qryCheckBoxPaper(query);

        return Result.ok(list);
    }
    @PostMapping("getCheckBoxPaperList")
    @Operation(summary = "获取试卷多选列表")
    public Result<List<SysCheckBoxVO>> getCheckBoxPaperList(@RequestBody @Valid SysCheckBoxQuery query){
        List<SysCheckBoxVO> list = checkBoxService.qryCheckBoxPaperList(query);

        return Result.ok(list);
    }
    @PostMapping("getCheckBoxRandList")
    @Operation(summary = "获取随机多选题")
    public Result<List<SysCheckBoxVO>> getCheckBoxRandList(@RequestBody @Valid SysCheckBoxQuery query){
        List<SysCheckBoxVO> list = checkBoxService.qryCheckBoxRandList(query);

        return Result.ok(list);
    }
    @PostMapping("/updateCheckBox")
    @Operation(summary = "修改多选")
    public Result<String> updateCheckBox(@RequestBody @Valid SysCheckBoxVO vo){
        checkBoxService.updateCheckBox(vo);

        return Result.ok();
    }
    @PostMapping("save")
    @Operation(summary = "保存")
    public Result<String> save(@RequestBody SysCheckBoxVO vo){
        checkBoxService.addCheckBox(vo);

        return Result.ok();
    }

    @DeleteMapping
    @Operation(summary = "删除")
    public Result<String> delete(@RequestBody List<Long> idList){

        checkBoxService.delete(idList);
        return Result.ok();
    }
}

